<?php

namespace app\components\helpers;

class ArrayHelper
{
    /**
     * 数组驼峰下标转下划线
     * @param $arr
     * @return array
     */
    public static function humpToUnderline($arr)
    {
        if (!is_array($arr))
            return $arr;

        $resultArr = [];
        foreach ($arr as $i => $v)
            $resultArr[strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', $i))] = $v;

        return $resultArr;
    }
}